package top.ssss;

import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextClosedEvent;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;

public class StartupControllerUrlPrinter
 implements ApplicationListener<ContextRefreshedEvent>
{
    private final RequestMappingHandlerMapping handlerMapping;

    public StartupControllerUrlPrinter(RequestMappingHandlerMapping handlerMapping){
        this.handlerMapping = handlerMapping;
    }

    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {
        handlerMapping.getHandlerMethods().forEach((k,v)->{
            System.out.println(k+" ==> "+v);
        });
    }
}
